
from django.db import models

# Create your models here.
from django.utils import timezone

USER_CHOOSE = [
    ('Admin', 'Admin'),
    ('Tester', 'Tester')
]

FIND_TYPE_CHOOSE = [
    ('xPath', 'xPath'),
    ('cssSelector', 'cssSelector')
]


class UISystem(models.Model):
    id = models.AutoField(primary_key=True)
    system_name = models.CharField(max_length=200, blank=True, verbose_name="系统名称")
    create_by = models.CharField(max_length=200, blank=True, verbose_name="创建者", default="Tester")
    create_time = models.DateTimeField(u'创建时间', auto_now_add=True, editable=True, null=True)
    update_time = models.DateTimeField(u'更新时间', auto_now=True, null=True)


class UIModel(models.Model):
    id = models.AutoField(primary_key=True)
    model_name = models.CharField(max_length=200, blank=True, verbose_name="页面名称")
    system_id = models.CharField(max_length=200, blank=True, verbose_name="系统ID")
    create_by = models.CharField(max_length=200, blank=True, verbose_name="创建者", default="Tester")
    create_time = models.DateTimeField(u'创建时间', auto_now_add=True, editable=True, null=True)
    update_time = models.DateTimeField(u'更新时间', auto_now=True, null=True)


class UIPage(models.Model):
    id = models.AutoField(primary_key=True)
    page_name = models.CharField(max_length=200, blank=True, verbose_name="页面名称")
    page_path = models.CharField(max_length=200, blank=True, verbose_name="页面路径")
    model_id = models.CharField(max_length=200, blank=True, verbose_name="模块ID")
    system_id = models.CharField(max_length=200, blank=True, verbose_name="系统ID")
    create_by = models.CharField(max_length=200, blank=True, verbose_name="创建者", default="Tester")
    create_time = models.DateTimeField(u'创建时间', auto_now_add=True, editable=True, null=True)
    update_time = models.DateTimeField(u'更新时间', auto_now=True, null=True)


class UIElement(models.Model):
    id = models.AutoField(primary_key=True)
    element_name = models.CharField(max_length=200, blank=True, verbose_name="元素名称")
    page_id = models.IntegerField(u'PageID', default=None)
    find_type = models.CharField(max_length=200, blank=True, verbose_name="定位方法", choices=FIND_TYPE_CHOOSE,
                                 default=FIND_TYPE_CHOOSE[0][0])
    find_param = models.CharField(max_length=200, blank=True, verbose_name="定位参数")
    another_find_type = models.CharField(max_length=200, blank=True, verbose_name="备用定位方法",
                                         choices=FIND_TYPE_CHOOSE, default=FIND_TYPE_CHOOSE[1][0])
    another_find_param = models.CharField(max_length=200, blank=True, verbose_name="备用定位参数")
    create_by = models.CharField(max_length=200, blank=True, verbose_name="创建者", default="Tester")
    create_time = models.DateTimeField(u'创建时间', auto_now_add=True, editable=True, null=True)
    update_time = models.DateTimeField(u'更新时间', auto_now=True, null=True)


class UIScenarios(models.Model):
    id = models.AutoField(primary_key=True)
    scenarios_name = models.CharField(max_length=200, blank=True, verbose_name="业务名称")
    system_id = models.CharField(max_length=200, blank=True, verbose_name="系统ID")
    create_by = models.CharField(max_length=200, blank=True, verbose_name="创建者", default="Tester")
    create_time = models.DateTimeField(u'创建时间', auto_now_add=True, editable=True, null=True)
    update_time = models.DateTimeField(u'更新时间', auto_now=True, null=True)


class UIScenariosElements(models.Model):
    id = models.AutoField(primary_key=True)
    scenarios_id = models.CharField(max_length=200, blank=True, verbose_name="业务名称")
    system_id = models.CharField(max_length=200, blank=True, verbose_name="系统ID")
    model_id = models.CharField(max_length=200, blank=True, verbose_name="模块ID")
    page_id = models.CharField(max_length=200, blank=True, verbose_name="页面ID")
    element_id = models.CharField(max_length=200, blank=True, verbose_name="元素ID")
    operator = models.CharField(max_length=200, blank=True, verbose_name="元素操作")
    params = models.CharField(max_length=200, blank=True, verbose_name="操作参数")
    sort_id = models.CharField(max_length=200, blank=True, verbose_name="排序ID")
    create_by = models.CharField(max_length=200, blank=True, verbose_name="创建者", default="Tester")
    create_time = models.DateTimeField(u'创建时间', auto_now_add=True, editable=True, null=True)
    update_time = models.DateTimeField(u'更新时间', auto_now=True, null=True)